package com.rsk.api.info;


import javax.ws.rs.QueryParam;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.rsk.aop.ParamCheck;
import com.rsk.api.common.ReturnUtils;
import com.rsk.service.info.RskInfoTabService;
import com.rsk.utils.result.Result;
import com.rsk.utils.result.ResultBuilder;
import com.rsk.utils.result.ResultCode;
import com.rsk.utils.tools.PageUtils;

@RestController
@RequestMapping(value="/rsk/info/tab")
public class RskInfoTabApi {
	
	@Reference(interfaceClass = RskInfoTabService.class, protocol = "dubbo")
	private RskInfoTabService rskInfoTabService;
	
	
	//@RequiresPermissions("coursecategory:save")
	@PostMapping(value="/saveInfoTab" )
	public Result<String> saveInfoTab(
			@QueryParam("labelName") @ParamCheck(notNull=true) String labelName,
		   	@QueryParam("labelRemarks") String labelRemarks,
		   	@RequestHeader("Authorization") String Authorization){
		//数据校验
		//String operatorUser = JwtUtil.getClaim(Authorization, "account");
		Long operatorUser = 123L;
		int i = rskInfoTabService.saveInfoTab(labelName, labelRemarks, operatorUser);
		return ReturnUtils.returnDataByOne(i);
	}
	
	//@RequiresPermissions("coursecategory:update")
	@PostMapping(value="/updateInfoTab" )
	public Result<String> updateInfoTab(@QueryParam("id") @ParamCheck(notNull=true) Long id,
								        @QueryParam("labelName") @ParamCheck(notNull=true) String labelName,
								        @QueryParam("labelRemarks") String labelRemarks,
							            @RequestHeader("Authorization") String Authorization){
		//数据校验
		//String operatorUser = JwtUtil.getClaim(Authorization, "account");
		Long operatorUser = 123L;
		//int i = rskCourseService.updateRskCourse(id, categoryId, courseName, courseIntroduction, courseUrl, courseCover, isRecommend, isOriginal, isSee, operatorUser)
		int i = rskInfoTabService.updateInfoTab(id, labelName, labelRemarks, operatorUser);
		return ReturnUtils.returnDataByOne(i);
	}
	
	
	//@RequiresPermissions("coursecategory:del")
	@PostMapping(value="/delInfoTab" )
	public Result<String> delInfoTab(@QueryParam("id") @ParamCheck(notNull=true) Long id,
									 @RequestHeader("Authorization") String Authorization){
		//String operatorUser = JwtUtil.getClaim(Authorization, "account");
		Long operatorUser = 123L;
		int i = rskInfoTabService.delInfoTab(id, operatorUser);
		return ReturnUtils.returnDataByOne(i);
	}
	

	@SuppressWarnings("rawtypes")
	@PostMapping(value="/selectInfoTabByPage" )
	public Result<PageUtils> selectInfoTabByPage(
			@QueryParam("nowPage") @ParamCheck(notNull=true) Integer nowPage,
			@QueryParam("pageSize") @ParamCheck(notNull=true) Integer pageSize,
			@QueryParam("labelName") String labelName,
			@RequestHeader("Authorization") String Authorization){
		//String operatorUser = JwtUtil.getClaim(Authorization, "account");
		PageUtils page = rskInfoTabService.selectInfoTabByPage(labelName, nowPage, pageSize);
		return ResultBuilder.success(page, ResultCode.SUCCESS);
	}
}
